{% extends 'admin/dashboard.html' %}

{% block content %}
<div class="card">
    <h2 class="text-xl font-bold mb-4">案例列表</h2>
    <a href="{{ url_for('admin_cases_add') }}" class="inline-block mb-4 px-4 py-2 bg-primary text-white rounded">添加案例</a>
    <table class="min-w-full divide-y divide-gray-200">
        <thead class="bg-gray-50">
            <tr>
                <th scope="col" class="table-header">标题</th>
                <th scope="col" class="table-header">描述</th>
                <th scope="col" class="table-header">图片</th>
                <th scope="col" class="table-header">操作</th>
            </tr>
        </thead>
        <tbody class="bg-white divide-y divide-gray-200">
            {% for case in cases %}
            <tr>
                <td class="table-data">{{ case.title }}</td>
                <td class="table-data">{{ case.description[:50] }}...</td>
                <td class="table-data">
                    {% if case.image_url %}
                    <img src="{{ case.image_url }}" alt="{{ case.title }}" class="w-16 h-16 object-cover">
                    {% endif %}
                </td>
                <td class="table-data">
                    <a href="#" class="text-primary hover:text-primary/80">编辑</a>
                    <a href="#" class="text-red-500 hover:text-red-700 ml-2">删除</a>
                </td>
            </tr>
            {% endfor %}
        </tbody>
    </table>
</div>
{% endblock %}